//
//  QLDrawPDFAnnotation.m
//  QLDemoProject
//
//  Created by Paramita on 2020/5/9.
//  Copyright © 2020 paramita. All rights reserved.
//

#import "QLDrawPDFAnnotation.h"

@implementation QLDrawPDFAnnotation

- (void)drawWithBox:(PDFDisplayBox)box inContext:(CGContextRef)context {

    [super drawWithBox:box inContext:context];
    UIGraphicsPushContext(context);
    CGContextSaveGState(context);

//    self.bounds = rect;
//    CGRect pageBounds = CGRectMake(0, 0, rect.size.width, rect.size.height);
//    CGContextTranslateCTM(context, 0, pageBounds.size.height);
//    CGContextScaleCTM(context, 1.0, -1.0);
    
    if (self.path) {
        [self.color setStroke];
        [self.path stroke];
        
    } else if (self.image) {
        
        PDFRect rect = [self.page boundsForBox:box];
        CGContextDrawImage(context, rect, [self.image CGImage]);
    }

    CGContextRestoreGState(context);
    UIGraphicsPopContext();
}

@end
